﻿#include "DAAbstractNodeWidget.h"
#include "DAAbstractNodeGraphicsItem.h"
#include <QVBoxLayout>
class DAAbstractNodeWidgetPrivate
{
    DA_IMPL_PUBLIC(DAAbstractNodeWidget)
public:
    DAAbstractNodeWidgetPrivate(DAAbstractNodeWidget *p);

    DAAbstractNodeGraphicsItem *_nodeItem;
};

DAAbstractNodeWidgetPrivate::DAAbstractNodeWidgetPrivate(DAAbstractNodeWidget *p) : q_ptr(p), _nodeItem(nullptr) {}

DAAbstractNodeWidget::DAAbstractNodeWidget(QWidget *parent, Qt::WindowFlags f)
    : QWidget(parent, f), d_ptr(new DAAbstractNodeWidgetPrivate(this))
{
}

DAAbstractNodeWidget::DAAbstractNodeWidget(DAAbstractNodeGraphicsItem *item, QWidget *parent, Qt::WindowFlags f)
    : QWidget(parent, f), d_ptr(new DAAbstractNodeWidgetPrivate(this))
{
    setNodeItem(item);
}

DAAbstractNodeWidget::~DAAbstractNodeWidget() {}

void DAAbstractNodeWidget::setNodeItem(DAAbstractNodeGraphicsItem *item)
{
    d_ptr->_nodeItem = item;
}

DAAbstractNodeGraphicsItem *DAAbstractNodeWidget::getNodeItem() const
{
    return (d_ptr->_nodeItem);
}

DAAbstractNode *DAAbstractNodeWidget::getNode() const
{
    if (d_ptr->_nodeItem) {
        return (d_ptr->_nodeItem->node());
    }
    return (nullptr);
}
